<?php
/**
 * Created by PhpStorm.
 * User: davin
 * Date: 14-10-19
 * Time: 下午12:03
 *
 * 管理员类
 */

use LaravelBook\Ardent\Ardent;

class Staff extends Ardent{

    public static $rules = array(
        'name' => 'required|between:1,50',
    );

    public static $relationsData = array(
        'user' => array(self::MORPH_ONE, 'User', 'name' => 'attach'),
    );

    public function beforeDelete( $forced = false )
    {
        try {
            $this->user->delete($forced);
        } catch(Execption $e) {
            $this->errors()->add('error', $e->getMessage());
            return false;
        }

        return true;
    }

    public function currentRoleIds(){
        return $this->user->currentRoleIds();
    }

} 